﻿#region NeoPatterns
// 
// NeoPatterns framework is released under LGPLv3 license.
// See http://www.opensource.org/licenses/lgpl-3.0.html for more details.
// 
// Please visit http://neopatterns.wikidot.com for more information about NeoPatterns
// 
// Copyright (c) Pascal Craponne 2008
// 
#endregion

using System;

namespace NeoPatterns.Patterns.Prototype
{
    /// <summary>
    /// Allows to use an instance as a prototype
    /// Copies of such instance can be created
    /// </summary>
    public interface IPrototyper
    {
        /// <summary>
        /// Clones object, given target type
        /// </summary>
        /// <param name="prototype"></param>
        /// <param name="targetType"></param>
        /// <returns></returns>
        object CloneAs(object prototype, Type targetType);

        /// <summary>
        /// Clone object, given source and target type, generic version
        /// </summary>
        /// <typeparam name="TTarget"></typeparam>
        /// <typeparam name="TSource"></typeparam>
        /// <param name="prototype"></param>
        /// <returns></returns>
        TTarget CloneAs<TTarget, TSource>(TSource prototype);

        /// <summary>
        /// Clone object, given target type, generic version 
        /// </summary>
        /// <typeparam name="TTarget"></typeparam>
        /// <param name="prototype"></param>
        /// <returns></returns>
        TTarget CloneAs<TTarget>(object prototype);

        /// <summary>
        /// Clone object, simple version
        /// </summary>
        /// <typeparam name="TObject"></typeparam>
        /// <param name="prototype"></param>
        /// <returns></returns>
        TObject Clone<TObject>(TObject prototype);

        /// <summary>
        /// Clones object, with a type to copy reflection from, and a type to target
        /// </summary>
        /// <param name="prototype"></param>
        /// <param name="prototypeType">Prototype type to copy reflection information from</param>
        /// <param name="targetType"></param>
        /// <returns></returns>
        object CloneAs(object prototype, Type prototypeType, Type targetType);
    }
}
